<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .thr {
        text-decoration: line-through;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <input type="text" v-model="value" /><button @click="add">添加</button>

      <ul>
        <li v-for="item in list" :class="{thr: item.checked}">
          <input type="checkbox" v-model="item.checked" />{{ item.name }}
        </li>
      </ul>

      <button @click="removeAll">删除所选</button>
    </div>

    <script src="./Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            list: [
              {
                id: 1,
                name: "zhangsan",
                checked: false,
              },
              {
                id: 2,
                name: "lisi",
                checked: false,
              },
            ],
            value: "",
          };
        },
        methods: {
          add() {
            this.list.push({
              id: new Date().getTime(),
              name: this.value,
              checked: false,
            });
            this.value = "";
          },
          removeAll() {
            this.list = this.list.filter((item) => !item.checked);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
